package com.fuhe.studydemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import com.fuhe.studydemo.custom.DrawRelativeLayout;
import com.fuhe.studydemo.custom.OffsetLayout;

import java.util.ArrayList;
import java.util.List;

public class DrawActivity extends Activity {

    private Spinner spinner;
    private DrawRelativeLayout draw_relative_layout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_draw);

        initView();
    }

    private void initView() {
        draw_relative_layout = findViewById(R.id.draw_relative_layout);

        spinner = findViewById(R.id.spinner);
        List<Integer> data =new ArrayList<>();
        data.add(0);
        data.add(1);
        data.add(2);
        data.add(3);
        data.add(4);
        data.add(5);
        final ArrayAdapter<Integer> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, data);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);

        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                draw_relative_layout.setDrawType(adapter.getItem(position));
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

}
